package org.ssssssss.magicapi.dialect;

import org.ssssssss.magicapi.modules.BoundSql;


public class SQLiteDialect implements Dialect {
    public SQLiteDialect() {
//        super();
//        registerColumnType(Types.BIT, "integer");
//        registerColumnType(Types.TINYINT, "tinyint");
//        registerColumnType(Types.SMALLINT, "smallint");
//        registerColumnType(Types.INTEGER, "integer");
//        registerColumnType(Types.BIGINT, "bigint");
//        registerColumnType(Types.FLOAT, "float");
//        registerColumnType(Types.REAL, "real");
//        registerColumnType(Types.DOUBLE, "double");
//        registerColumnType(Types.NUMERIC, "numeric");
//        registerColumnType(Types.DECIMAL, "decimal");
//        registerColumnType(Types.CHAR, "char");
//        registerColumnType(Types.VARCHAR, "varchar");
//        registerColumnType(Types.LONGVARCHAR, "longvarchar");
//        registerColumnType(Types.DATE, "date");
//        registerColumnType(Types.TIME, "time");
//        registerColumnType(Types.TIMESTAMP, "timestamp");
//        registerColumnType(Types.BINARY, "blob");
//        registerColumnType(Types.VARBINARY, "blob");
//        registerColumnType(Types.LONGVARBINARY, "blob");
//        // registerColumnType(Types.NULL, "null");
//        registerColumnType(Types.BLOB, "blob");
//        registerColumnType(Types.CLOB, "clob");
//        registerColumnType(Types.BOOLEAN, "integer");
//
//        registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", ""));
//        registerFunction("mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "?1 % ?2"));
//        registerFunction("substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING));
//        registerFunction("substring", new StandardSQLFunction("substr", StandardBasicTypes.STRING));
    }

    @Override
    public boolean match(String jdbcUrl) {
        return jdbcUrl.contains(":sqlite:");
    }

    @Override
    public String getPageSql(String sql, BoundSql boundSql, long offset, long limit) {
        boundSql.addParameter(offset);
        boundSql.addParameter(limit);
        return sql + " limit ?,?";
    }
}
